import axios from 'axios';
export async function checkVersion() {
    const prefixUrl = window.location.href.split('#')[0]
    const versionUrl = `${prefixUrl}version.json`;
    try {
        const res = await axios.get(versionUrl, { headers: { 'Cache-Control': 'no-cache' } });
        const newVersion = res.data.version;
        const localVersion = window.localStorage.getItem('version');
        window.localStorage.setItem('version', newVersion);
        if (localVersion && Number(localVersion) !== newVersion) {
            console.log('[ Version ]', localVersion, newVersion)
            console.log('发现新版本，刷新页面');
            window.location.reload();
        }
    } catch (error) {
        console.log('获取线上版本号失败 utils/version.js Error:', error);
    }
}